package ${controller.packageName};

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import ${serviceInterface.packageName}.${serviceInterface.fileName};
import ${domainCmd.packageName}.${tableClass.shortClassName}Cmd;
import ${domainUpd.packageName}.${tableClass.shortClassName}Upd;
import ${domainQry.packageName}.${tableClass.shortClassName}Qry;
import ${domainVo.packageName}.${tableClass.shortClassName}Vo;

<#assign classNameLower = tableClass.shortClassName?substring(0,1)?lower_case + tableClass.shortClassName?substring(1) />
@RestController
@RequestMapping("/api/${tableClass.shortClassName}")
@Tag(name = "${tableClass.remark!}管理", description = "提供查询、更新、删除和分页功能")
public class ${tableClass.shortClassName}Controller {

    @Autowired
    private ${tableClass.shortClassName}Service ${classNameLower}Service;

    @GetMapping("/findById")
    @Operation(summary = "根据id查询", description = "根据id查询")
    public ${tableClass.shortClassName}Vo findById(@RequestParam Long id) {
        return ${classNameLower}Service.findOne(id);
    }


    @DeleteMapping("/deleteById")
    @Operation(summary = "根据ID删除", description = "根据ID删除")
    public Boolean deleteById(@RequestParam Long id) {
    return ${classNameLower}Service.deleteOne(id);
    }

    @PostMapping("/updateById")
    @Operation(summary = "根据id更新", description = "根据id更新")
    public Boolean updateById(@RequestBody ${tableClass.shortClassName}Upd upd) {
        return ${classNameLower}Service.updateOne(upd);
    }

    @PostMapping("/findPage")
    @Operation(summary = "分页查询", description = "分页查询")
    public IPage<${tableClass.shortClassName}Vo> findPage(@RequestBody ${tableClass.shortClassName}Qry qry) {
        return ${classNameLower}Service.findPage(qry);
    }

    @PostMapping("/save")
    @Operation(summary = "保存", description = "保存")
    public Boolean save(@RequestBody ${tableClass.shortClassName}Cmd cmd) {
        return ${classNameLower}Service.createOne(cmd);
    }
}
